/*
 * Copyright (C) 2011 Project R'yleh Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.Arkham;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

public class Practice extends Activity implements OnClickListener 
{
	public  ViewCore GLView;
	
	private View mathButton;
	private View vocabButton;
	private TextView answerTF;
	private TextView answerTime;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(com.Arkham.R.layout.practicemenu);
        
        mathButton = findViewById(com.Arkham.R.id.mathgame_button);
        mathButton.setOnClickListener(this);  
        vocabButton = findViewById(com.Arkham.R.id.vocabgame_button);
        vocabButton.setOnClickListener(this);
        
        answerTF = (TextView)findViewById(com.Arkham.R.id.answerTF);
        answerTF.setOnClickListener(this);
        answerTime = (TextView)findViewById(com.Arkham.R.id.answerTime);
        answerTime.setOnClickListener(this);
        
        answerTF = (TextView)findViewById(com.Arkham.R.id.answerTF);
        answerTF.setOnClickListener(this);
        answerTime = (TextView)findViewById(com.Arkham.R.id.answerTime);
        answerTime.setOnClickListener(this);
	}
	
	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data){
		super.onActivityResult(requestCode, resultCode, data);
		if(requestCode == 100){
			Bundle bundle = data.getExtras();
			answerTF.setText(Boolean.toString(bundle.getBoolean("ANS")));
			answerTime.setText(Double.toString((double)bundle.getLong("TIME")/1000));
			
		}
		if(requestCode == 200){
			Bundle bundle = data.getExtras();
			answerTF.setText(Boolean.toString(bundle.getBoolean("ANS")));
			answerTime.setText(Double.toString((double)bundle.getLong("TIME")/1000));
			
		}
	}
	
    public void onClick(View v) {
    	Intent i;
    	switch (v.getId())
    	{
    	case com.Arkham.R.id.mathgame_button:
    		i = new Intent(this, MathGame.class);
	    	//startActivity(i);
	    	startActivityForResult(i, 200);
	    	break;
    	case com.Arkham.R.id.vocabgame_button:
    		i = new Intent(this, VocabGame.class);
//	    	startActivity(i);
    		startActivityForResult(i, 100);
    	    break;
    	}
    }
}